Before the advent of the graphical user interface (GUI), in which a command is typically issued by moving a pointer (e.g., a mouse cursor) and/or pressing a key (i.e., “clicking”, often on a key mounted on a mouse), the predominant way a user interacted with a computer was by entering a command on a command line. Although seemingly more “primitive”, this means of communication is more direct, and is often more powerful and more flexible than the directed pathways defined by a GUI. Most new applications that are written are still written to be accessible directly by entering a textual command at a command prompt.
The command line entered at a command line prompt (e.g., “C:\>”) is frequently complex. Sometimes the command line is of the form:
<DoSomething> <how> <ToASomething>or<DoSomething> <how> <ToAnInputFile> > <CreatingAnOutputFile>
where DoSomething corresponds to an action, how describes how the action should be executed, for instance, and ToASomething corresponds to the object acted upon (often one or more files). The fourth “>” in the second example is a redirection character, telling the operating system to send the output of the previous commands (i.e., those to the left of the fourth “>”) to some other place (i.e., that place indicated by the characters to the right of the fourth “>”, in this case, to the OutputFile).
Because of the complexity of command lines, the command line is often validated or parsed by the application to determine if it has been entered correctly before the application attempts to execute the command. Parsing usually is done by breaking down text into recognized strings of characters and analyzing the grammatical structure of the strings, with respect to a given formal grammar.
Frequently, however, applications and therefore the commands that execute the applications change. This usually requires the parsing code to change, a nontrivial programming exercise. It would be helpful if there were a way to make a generic parser that could be used by many different applications over their lifetimes, without requiring recoding of the parser.